package day326;

import common.TreeNode;

/**
 * @author tmh
 * @date 2023/3/26 18:47
 * @description 翻转二叉树
 */
public class T226 {
    public TreeNode invertTree(TreeNode root) {
        if(root==null){
            return null;
        }
        swap(root);
        invertTree(root.left);
        invertTree(root.right);
        return root;
    }

    public void swap(TreeNode root){
        TreeNode treeNode;
        treeNode=root.right;
        root.right=root.left;
        root.left=treeNode;
    }
}
